package com.ymatou.iapi.productprice.testcase.old20210121;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.shop2cn.iapi.activitymgt.parameter.AddactivityBean;
import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.ProductDetailsDto;
import com.ymatou.iapi.productmanager.parameter.product.AddSellerProductRequest;
import com.ymatou.iapi.productprice.parameter.PriceConfig;
import com.ymatou.iapi.productprice.parameter.ProductAllPriceBean;
import com.ymatou.iapi.productprice.parameter.ProductPriceBean;
import com.ymatou.iapi.productprice.service.GetPriceByProdIdCall;
import com.ymatou.iapi.productquery.parameter.GetProductInfoByProductIdBean;
import com.ymatou.iapi.userregister.parameter.UserRegisterInfoRequestDtoBean;
import com.ymatou.iapi.userregister.service.UserRegisterInfoRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.*;
import com.ymttest.database.model.YmtCatalogsI;
import com.ymttest.database.model.YmtProductActivityStock;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductTimeStampWapper;
import com.ymttest.database.mongo.jproduct.ProductsWapperV2;
import com.ymttest.database.redis.ImRedisWapper;
import com.ymttest.database.sqlwapper.YmtCatalogsIWapper;
import com.ymttest.database.sqlwapper.YmtProductActivityStockWapper;
import com.ymttest.utils.AgentUsers;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;
import com.ymttest.utils.YMTDateUtil;
import org.junit.*;
import org.junit.experimental.categories.Category;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Ignore
public class Ts_GetPriceByProdId {
	private static int newBuyerId = ProductPriceCallService.getNewCustomer();
	private static int oldBuyerId = ProductPriceCallService.getOldCustomer();
	private static GetPriceByProdIdCall getPriceByProdIdCall = new GetPriceByProdIdCall();
	private static ProductTimeStampWapper productTimeStampWapper = new ProductTimeStampWapper();
	private static ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
	private static int sellerId = Integer.parseInt(EnvSetup.getData("autotest_seller1"));
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("非交易隔离查询接口, 根据商品id查询商品价格");
		try {
			GodfreightmgrService.deleteBySellerId(rootUserId);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Before
	public void caseUp() {
		
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getPriceByProdIdCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_001() {
		Logger.start(true, "非交易隔离,普通新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();

			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			Logger.comment("1 码头新客户##########################");
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格逻辑
			
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			Logger.comment("2 vip##########################");
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			//no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);

			Logger.comment("2 no vip##########################");
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
				}else{
					ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
					ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				}
				
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
			//	productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				Logger.comment("新客修改后价格检查");
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				Logger.comment("老客修改后价格检查");
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceUpdate);
			}
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_002() {
		Logger.start(true, "非交易隔离,非新人活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
		
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			
			//2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				
				if (PriceConfig.isCacheActivityProduct){
					ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
					ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
					
				}else{
					ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
					ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
					
					ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,false,false);
					ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceUpdate);
				}
				
				
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				//productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,true,false);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBeanUpdate,false,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceUpdate);
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_003() {
		Logger.start(true, "交易隔离,新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
		
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			//no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
				
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				//productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,true);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceUpdate);
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_004() {
		Logger.start(true, "交易隔离,非新人活动");
		try {

			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
		
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			
			//2码头老客户查询结果为普通商品价格
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			//no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean,inaid);
				
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
				
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
				//productTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date(),"cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,true);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceUpdate);
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_005() {
		Logger.start(true, "普通商品");
		try {
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId,0);
		
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			//2码头老客户查询结果为普通商品价格
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			//no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
			ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库价格，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				ProductAllPriceBean productAllPriceBeanUpdate = ProductPriceCallService.updatePriceInMgo(productAllPriceBean);
				
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
				
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
				
				//修改时间戳，应该查询mongo库中数据，结果发生变化
			//	productTimeStampWapper.update(productId, MapUtil.hashMap("cut",new Date()));
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,true);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				ProductPriceBean oldProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBeanUpdate,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceUpdate);
			}
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_006() {
		Logger.start(true, "活动结束，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
		
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			//2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库活动商品结束时间，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				//activityProductsWapper.update(inaid, MapUtil.hashMap("end",YMTDateUtil.getBeforeOrNextDate(-1)));
				AdminCallService.closeProductInActivity(String.valueOf(inaid));
				
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				//vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);

				//no vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
				ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			}
			
			
			
			
		}catch (Exception e) {
			Logger.fail(e);
		}
		
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_007() {
		Logger.start(true, "活动库存清零，应显示原价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();
		
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			//2码头老客户查询结果为活动价格
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			if (PriceConfig.isCacheCheck){
				Logger.debug("缓存检查");
				//===========================================================================================================
				//修改mongo数据库活动库存，由于时间戳没有变化，应该查询缓存中数据，所以结果没有变
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);
				ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);

				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);
				
				//老客修改后价格检查
				//vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);

				//no vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
				ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			}
			
			
		}catch (Exception e) {
			Logger.fail(e);
		}
		
	}
	
	
	
	



	/**
	 * 有活动价和新客价时，取活动价
	 */
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_009() {
		Logger.start(true, "非交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation_Member();
			String productId = productAllPriceBean.getProductId();

			int prodInActivityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());

			//新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			Logger.debug("priceIgnoreActivity_NewCust:"+priceIgnoreActivity_NewCust);
			//新客 会员价
			ProductPriceBean priceIncludeActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			//老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			//老客 会员价
			ProductPriceBean priceIncludeActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
			
			
			//会员政策1， 会员等级3以上才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");


			//0级会员 新客 普通价
			JsonObject ret1 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret1, priceIgnoreActivity_NewCust);
			
			//6级会员  老客 会员活动价
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, priceIncludeActivity_OleCust);
			
			
			//会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2, "2015-01-02 00:00:00,2016-03-23 23:59:59");

			//新客 注册时间2015-05-26 14:20:04 会员活动价
			JsonObject ret3 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret3, priceIncludeActivity_NewCust);
			
			//老客 注册时间2016-04-22 10:19:05 普通价格
			JsonObject ret4 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret4, priceIgnoreActivity_OleCust);
			
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 3 
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "3");

			//新客  标签3  会员活动价
			JsonObject ret5 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret5, priceIncludeActivity_NewCust);
			
			//老客 没标签 普通价格
			JsonObject ret6 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret6, priceIgnoreActivity_OleCust);
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 4
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "4");

			//新客  标签3  普通价
			JsonObject ret7 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret7, priceIgnoreActivity_NewCust);
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_013() {
		Logger.start(true, "非交易隔离,新客活动，现在新客价");
		try {
			AddSellerProductRequest addpro = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			Thread.sleep(2000);

			//0级会员 新客 普通价
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			JsonObject retBean = ret.get("Data").getAsJsonObject().get("PriceInfo").getAsJsonObject();
			JsonArray catalogsJsonArray = retBean.get("Catalogs").getAsJsonArray();
			Logger.verifyEquals("200",ret.get("Code").getAsString(),"验证Code");
			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			for (int i=0;i<catalogsJsonArray.size();i++){
				JsonObject catalogInfo = catalogsJsonArray.get(i).getAsJsonObject();
				YmtCatalogsI ymtCatalogsI = ymtCatalogsIList.get(i);
				if (catalogInfo.get("CatalogId").getAsString().equals(ymtCatalogsIList.get(i).getsCatalogId())){
					Logger.verifyEquals(catalogInfo.get("Price").getAsDouble(),ymtCatalogsI.getfNewCustomerPrice(),"验证价格是新客价");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_014() {
		Logger.start(true, "非交易隔离,商品报名活动,新客活动，显示活动价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation_Member();
			String productId = productAllPriceBean.getProductId();

			int prodInActivityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());

			//0级会员 新客 普通价
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			JsonObject retBean = ret.get("Data").getAsJsonObject().get("PriceInfo").getAsJsonObject();
			JsonArray catalogsJsonArray = retBean.get("Catalogs").getAsJsonArray();
			Logger.verifyEquals("200",ret.get("Code").getAsString(),"验证Code");
			List<YmtProductActivityStock> ymtProductActivityStocks = new YmtProductActivityStockWapper().selectByProductId(productId);
			for (int i=0;i<catalogsJsonArray.size();i++){
				JsonObject catalogInfo = catalogsJsonArray.get(i).getAsJsonObject();
				YmtProductActivityStock ymtCatalogsI = ymtProductActivityStocks.get(i);
				if (catalogInfo.get("CatalogId").getAsString().equals(ymtProductActivityStocks.get(i).getScatalogid())){
					Logger.verifyEquals(catalogInfo.get("Price").getAsDouble(),ymtCatalogsI.getfActivityPrice(),"验证价格是活动价");
					Logger.verifyEquals(catalogInfo.get("ActivityId").getAsInt(),ymtCatalogsI.getIactivityid(),"验证活动id");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_010() {
		Logger.start(true, "交易隔离,会员活动");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndIsolation_Member();
			String productId = productAllPriceBean.getProductId();
			
			
			int prodInActivityId = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
			
			//新客 普通价
			ProductPriceBean priceIgnoreActivity_NewCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,true);
			//老客 普通价
			ProductPriceBean priceIgnoreActivity_OleCust = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,true);
			//原价
			ProductPriceBean priceIgnoreActivity_OleOrig = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean,true);
			
			
			//会员政策1， 会员等级3以上才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 1, "3,4,5,6");
			//0级会员 新客 普通价
			JsonObject ret1 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret1, priceIgnoreActivity_NewCust);
			
			//6级会员  老客 普通价
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, priceIgnoreActivity_OleCust);
			
			
			//会员政策2，会员注册时间在2017-01-02 到 2017-03-23 才能享受活动价
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId, 2, "2015-01-02 00:00:00,2016-03-23 23:59:59");
			
			//新客 注册时间2015-05-26 14:20:04  普通价
			JsonObject ret3 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret3, priceIgnoreActivity_NewCust);
			
			//老客 注册时间2016-04-22 10:19:05 普通价格
			JsonObject ret4 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret4, priceIgnoreActivity_OleCust);
			
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 3 
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "3");
			
			//新客  标签3  普通价

			JsonObject ret5 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret5, priceIgnoreActivity_NewCust);
			
			//老客 没标签 普通价格
			//vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			JsonObject ret6 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret6, priceIgnoreActivity_OleCust);
			
			//no vip
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
			ret6 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret6, priceIgnoreActivity_OleOrig);
			ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
			
			
			//会员政策3， 会员标签满足才能享受活动价  标签值 4
			ProductPriceCallService.updateActivityMemberPolicy(prodInActivityId,3, "4");
			
			//新客  标签3  普通价
			JsonObject ret7 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret7, priceIgnoreActivity_NewCust);
			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//时间太长 手动执行
	public void Tc_GetPriceByProdId_011() {
		Logger.start(true, "活动自然结束");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
			String productId = productAllPriceBean.getProductId();

			new ActivityProductsWapper().update(productId, MapUtil.hashMap("end",YMTDateUtil.getDateBeforeOrNextSecond(180)));
			new ProductTimeStampWapper().update(productId, MapUtil.hashMap("aut",YMTDateUtil.getDateBeforeOrNextSecond(180)));
			//1 码头新客户 查询结果为活动价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			
			YMTDateUtil.waitTime(300);
			//活动自然结束 恢复原价
			ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);
			
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_012() {
		Logger.start(true, "测试缓存ExtraDeliveryType,ExtraDeliveryFee");
		try {
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProductAllPrice(productId,0);
		
			//1 码头新客户 查询结果为普通商品价格
			ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);
			
			
			//修改ExtraDeliveryType,ExtraDeliveryFee ， 不修改时间戳
			new ProductsWapperV2().updateAll(MapUtil.hashMap("spid",productId), MapUtil.hashMap("mdeliv",2,"mflight",3.1));
			JsonObject ret1 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret1, newProductPrice);
			
			
			//修改时间戳
			//new ProductTimeStampWapper().update(productId, MapUtil.hashMap("sut",new Date()));
			ProductManagerCallServiceV3.updateProductRedisTimeStamp(productId);
			ProductPriceBean newProductPrice2 = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
			ProductPriceCallService.checkPriceItemV2(ret2, newProductPrice2);
			
		}catch(Exception e){
			Logger.fail(e);
		}
	}
			
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_999() {
		Logger.start(true, "非法数据测试");
		try {
			
			//不存在 商品id
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, "111212312");
			ProductPriceCallService.checkInvalidResponseV2(ret);
			
			//buyerid<0
			String productId = ProductPriceCallService.getProductIdWithAllPrice();
			JsonObject ret1 = getPriceByProdIdCall.callAndGetReturnData(-1, productId);
			ProductPriceCallService.checkInvalidResponseV2(ret1);
			
			//没有productid参数
			JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData();
			ProductPriceCallService.checkInvalidResponseV2(ret2);
			
		}catch (Exception e) {
			Logger.fail(e);
		}
	
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore //与其他活动时间冲突（活动ID：348344） 不可以一个商品参加多个活动，首先前置条件通过不了，建议在申请活动接口验证这个场景的case
	public void Tc_GetPriceByProdId_13() {
		Logger.start(true, "非法数据测试,一个商品参加多个活动");
		try {
			//创建商品
			AddSellerProductRequest addpro = ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);

			//获取商品ID
			String productId = ProductManagerCallServiceV3.AddSellerProduct(addpro);
			//获取规格ID
			List<String> catalogs = new YmtCatalogsIWapper().selectCatalogsByProductId(productId).stream().map(YmtCatalogsI::getsCatalogId).collect(Collectors.toList());
			//创建一个活动
			Integer activityId1 = ProductManagerCallServiceV2.createNoIsolationActivityInProcess();
			//报名活动  获得商品在活动中的id
			List<String> aids1 = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId, catalogs,activityId1, 100,"10");
			//审核通过
			ProductManagerCallServiceV2.approveProductInActivityV2(productId,aids1.get(0),true);
			//创建一个活动  非交易隔离活动
			Integer activityId2 = ProductManagerCallServiceV2.createNoIsolationActivityInProcessV2();
			//报名活动  获得商品在活动中的id
			List<String> aids2 = ProductManagerCallServiceV2.ApplyActivity(productId, sellerId, catalogs,activityId2, 100,"10");
			//与其他活动时间冲突（活动ID：348344）  不能参加多个商品
			//审核通过
		//	ProductManagerCallServiceV2.approveProductInActivity(productId,aids2.get(0),true);
		}catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_14() {
		Logger.start(true, "新哈尼客户，新客价");
		try {
			ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NewBuyerAndIsolation();
			String productId = productAllPriceBean.getProductId();
			UserRegisterInfoRequestDtoBean regbean = JUserCallService.initUserRegisterInfoRequestDtoBean();
			UserRegisterInfoRequestDtoCall urrc = JUserCallService.UserRegisterInfoRequestDtoCall(regbean);
			Integer userId = urrc.getUserid();

			Thread.sleep(2000);
			JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(userId, productId);
			JsonObject retBean = ret.get("Data").getAsJsonObject().get("PriceInfo").getAsJsonObject();
			JsonArray catalogsJsonArray = retBean.get("Catalogs").getAsJsonArray();
			Logger.verifyEquals("200",ret.get("Code").getAsString(),"验证Code");
			List<YmtCatalogsI> ymtCatalogsIList = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
			for (int i=0;i<catalogsJsonArray.size();i++){
				JsonObject catalogInfo = catalogsJsonArray.get(i).getAsJsonObject();
				YmtCatalogsI ymtCatalogsI = ymtCatalogsIList.get(i);
				if (catalogInfo.get("CatalogId").getAsString().equals(ymtCatalogsIList.get(i).getsCatalogId())){
					Logger.verifyEquals(catalogInfo.get("Price").getAsDouble(),ymtCatalogsI.getfNewCustomerPrice(),"验证价格是新客价");
				}
			}
		}catch (Exception e) {
			Logger.fail(e);
		}

	}
	
	
	
	//////////////////// 忽略case /////////////////////
	
	//渠道商
	private static int rootUserId = AgentUsers.rootUserId;
	private static String rootUserName = "NickautoTest";
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_GetPriceByProdId_15() {
		Logger.start(true, "查询限时抢八折后价格");
		try{
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(rootUserId,rootUserName,false);
			double price=123.6;
			addAgentProductBean.getCatalogList().forEach(a->{
				a.getAgentPriceList().forEach(b->{
					b.setAgentPrice(price);
				});
				a.setDirectPrice(price);
			});
		 	String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			//创建限时抢购活动
			List<String> catalogList =new ArrayList<String>();
			ProductDetailsDto selectProductDetails = AddAgentProductCallService.selectProductDetails(rootUserId,productId);
			selectProductDetails.getCatalogList().forEach(a->{
		 		catalogList.add(a.getCatalogId());
		 	});
			AddactivityBean initProductaddactivity = AgentProductCallService.initProductaddactivity(rootUserId, productId, catalogList);
			initProductaddactivity.getProductList().forEach(a->{
				a.getCatalogList().forEach(b->{
					b.setDiscount(new BigDecimal("8"));
				});
			});
			int activityId = AgentProductCallService.agentProductaddactivity(initProductaddactivity);
			Thread.sleep(4000);
			GetProductInfoByProductIdBean b=new GetProductInfoByProductIdBean();
			b.setNextActivityExpire(7);
			b.setProductId(productId);
			JsonObject jsonObject = getPriceByProdIdCall.callAndGetReturnData(rootUserId, productId);
			JsonObject catalogActivity1 = jsonObject.get("Data").getAsJsonObject().get("PriceInfo").getAsJsonObject().get("Catalogs").getAsJsonArray().get(0).getAsJsonObject();		
			JsonObject catalogActivity2 = jsonObject.get("Data").getAsJsonObject().get("PriceInfo").getAsJsonObject().get("Catalogs").getAsJsonArray().get(1).getAsJsonObject();		
			Logger.verifyEquals(price*0.8,catalogActivity1.get("Price").getAsDouble(), "验证是否为八折价格");
			Logger.verifyEquals(price*0.8,catalogActivity2.get("Price").getAsDouble(), "验证是否为八折价格");
			Logger.verifyEquals(price*0.8,catalogActivity1.get("ActivityPrice").getAsDouble(), "验证活动价是否为八折价格");
			Logger.verifyEquals(price*0.8,catalogActivity2.get("ActivityPrice").getAsDouble(), "验证活动价是否为八折价格");
		}catch(Exception e){
			Logger.fail(e);
		}
	}


	@Test
	@Ignore
	@Category(P1.class)
	@TestCase
	public void Tc_GetPriceByProdId_008() {
		Logger.start(true, "删除时间戳表后，查询");
		try{
			if (PriceConfig.isCacheCheck){
				ProductAllPriceBean productAllPriceBean = ProductPriceCallService.getProdPriceWithActivity_NoNewBuyerAndNoIsolation();
				String productId = productAllPriceBean.getProductId();
				//删除时间戳表记录
				//productTimeStampWapper.delete(productId);
				new ImRedisWapper().deleteProductTimeStamp(productId);
				//1 码头新客户 查询结果为活动价格
				ProductPriceBean newProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,true,false);
				JsonObject ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPrice);

				//2码头老客户查询结果为活动价格
				ProductPriceBean oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevel(productAllPriceBean,false,false);
				JsonObject ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);

				//修改mongo数据库活动库存
				int inaid = Integer.parseInt(activityProductsWapper.getByProdId(productId).get("inaid").toString());
				ProductPriceCallService.updateActivityStockTo0InMgo(productAllPriceBean, inaid);

				YMTDateUtil.waitTime(5);
				//新客修改后价格检查
				ProductPriceBean newProductPriceUpdate = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,true);
				ret = getPriceByProdIdCall.callAndGetReturnData(newBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret, newProductPriceUpdate);

				//老客修改后价格检查
				//vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);
				oldProductPrice = ProductPriceCallService.getProductPriceBeanByUserLevelAndIgnoreActivityPrice(productAllPriceBean,false);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPrice);

				//no vip
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, false);
				ProductPriceBean oldProductPriceNoVip = ProductPriceCallService.getProductOrigPriceBeanByUserLevel(productAllPriceBean, true);
				ret2 = getPriceByProdIdCall.callAndGetReturnData(oldBuyerId, productId);
				ProductPriceCallService.checkPriceItemV2(ret2, oldProductPriceNoVip);
				ProductPriceCallService.updateSellerBuyerToVipOrNot(ProductPriceCallService.sellerId, oldBuyerId, true);

			}
		}catch (Exception e) {
			Logger.fail(e);
		}
	}

}
